package org.peoplesearch.vk.executor;


import java.util.concurrent.atomic.AtomicInteger;

public class VkCommandCounting implements Runnable {

    private VkCommand command;
    private AtomicInteger count;

    public VkCommandCounting(VkCommand command, final AtomicInteger count) {
        this.command = command;
        this.count = count;
        count.incrementAndGet();
    }

    public void run() {
        try {
            try {
                command.run();
            } catch (Exception e) {

            }

        } finally {
            count.decrementAndGet();
            synchronized (count) {
                count.notify();
            }
        }
    }

}
